package com.api.rocky.app;

import org.json.JSONArray;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import com.api.rocky.R;
import com.api.rocky.Data.Global;
import com.api.rocky.Util.Util;

public class SetLoveWordActivity extends Activity {
	Button but_set;
	EditText edit_mood;
	Context setLoveWordActivity;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_set_love_word);
        edit_mood = (EditText) findViewById(R.id.mood_edit);
        
        but_set = (Button) findViewById(R.id.mood_set);
        but_set.setOnClickListener(new Button.OnClickListener() {
        	
			public void onClick(View arg0) {
				if(!edit_mood.getText().toString().equals("")){
					try{
						while(Global.LOCATION_CITY.equals("")){
							Thread.sleep(500);
						}
						JSONArray jsa = new JSONArray();
						jsa.put(5);
						jsa.put(edit_mood.getText().toString());
						jsa.put(Global.LOCATION_X);
						jsa.put(Global.LOCATION_Y);
						jsa.put(Global.LOCATION_CITY);
						Util.SendMessageToServer(Global.client, jsa.toString());
					}catch(Exception e){
						Log.e("set love word", e.toString());
					}
				}
			}
		});
    }
}
